package org.jeecg.sms.config;

import lombok.Data;
import org.jeecg.sms.constant.SmsConstant;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * SOC相关配置
 *
 * @author qiang.zhou
 * @createtime 2023-03-14  14:14
 */
@Data
@Component
@ConfigurationProperties(prefix = "soc")
public class SocProperties {

    /**
     * 短信配置
     **/
    private SmsProp sms = new SmsProp();

    @Data
    public static class SmsProp {

        private String target;

        private String pwd;

        /**
         * 短信验证码过期时间
         **/
        private Long smsCodeExpire = 60L;

        public void setSmsCodeExpire(Long smsCodeExpire) {
            if (null != smsCodeExpire && smsCodeExpire < SmsConstant.SMS_CODE_GAP) {
                throw new IllegalArgumentException("短信验证码过期时间配置值必须大于" + SmsConstant.SMS_CODE_GAP);
            }
            this.smsCodeExpire = smsCodeExpire;
        }

    }

}
